
import config from '@/config/config.js';
import axios from "axios";

const fixtureTypeRequest = {
    loadFixtureTypeList(searchFixtureType,pageNum,limit,callback){
        let url = config.fixtureUrl + "/fixtureType/list?pageNum=" + pageNum + "&limit=" + limit;
        if (searchFixtureType.fixtureTypeId){
            url += "&fixtureTypeId=" + searchFixtureType.fixtureTypeId
        }
        if (searchFixtureType.fixtureTypeName){
            url += "&fixtureTypeName=" + searchFixtureType.fixtureTypeName
        }
        if (searchFixtureType.fixtureTypeType){
            url += "&fixtureTypeType=" + searchFixtureType.fixtureTypeType
        }
        axios.get(url,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callback(res.data.data)
        })
    },
    loadUpdateInfo(fixtureTypeId,callback){
        let url = config.fixtureUrl + "/fixtureType/updateInfo?fixtureTypeId=" + fixtureTypeId;
        axios.get(url,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callback(res.data)
        })
    },
    deleteFixtureType(fixtureTypeId,callback){
        let url = config.fixtureUrl + "/fixtureType/delete?fixtureTypeId=" + fixtureTypeId
        return axios.delete(url, {
            headers: {
                token: localStorage.getItem("token")
            }
        }).then(res=>{
            callback(res.data)
        })
    },
    insertFixtureType(insertFixtureType,callback){
        let url = config.fixtureUrl + "/fixtureType/insert"
        axios.post(url,insertFixtureType,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callback(res.data)
        })
    },
    updateFixtureType(updateFixtureType,callback){
        let url = config.fixtureUrl + "/fixtureType/update"
        axios.put(url,updateFixtureType,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callback(res.data)
        })
    },
    loadAllColumn(callback){
        let url = config.fixtureUrl + "/fixtureType/allColumn"
        axios.get(url,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callback(res.data)
        })
    }
}
export default fixtureTypeRequest;